import  VueRouter from 'vue-router'
import Vue from 'vue'
// import Home from "../components/Home"
// import About from "../components/About"
// import User from "../components/User.vue"

//使用懒加载
const Home = () =>import('../components/Home.vue')
const HomeNew = () =>import('../components/HomeNew.vue')
const HomeMessage = () =>import('../components/HomeMessage.vue')
const About = () =>import('../components/About.vue')
const User = () =>import('../components/User.vue')

//1.通过Vue.use(插件)，安装插件
Vue.use(VueRouter)

//2.创建路由对象
const routes=[
    {
        path:"",
        redirect:"/home"
    },
    {
        path:"news",
        component:HomeNew
    },
    {
        path:"message",
        component:HomeMessage
    },
    {
        path:"/home",
        component:Home
    },
   
    {
        path:"/about",
        component:About
    },

    {
        path:"/user/:userid",
        component:User
    },
    
]
const router = new VueRouter({
    routes,
    mode:"history",
    linkActiveClass:'active'
})

// 3.将router对象传入到Vue实例中
export default router